{% comment %}
<!--
  Copyright (C) 2010 ZHENG Zhong <http://www.zhengzhong.net/>
  Created on 2010-05-11.
  $Id$
-->
{% endcomment %}

{% load ilike_tags %}

{% if dish %}

  <div id="dish-{{ dish.id }}" class="post">

    {% if dish.photo_url %}
      <div class="right">
        <img class="xs-photo" src="{{ dish.photo_url }}" alt="Photo"/>
      </div>
    {% endif %}

    <div class="post-head">
      <a href="{% url friday.search_dish %}?dish_name={{ dish.name|urlencode }}">{{ dish.name|escape }}</a>
      {% if dish.is_spicy %}
        <img class="icon" src="{{ static_ }}/images/spicy.png" alt="Spicy"/>
      {% endif %}
      {% if dish.is_vegetarian %}
        <img class="icon" src="{{ static_ }}/images/vegetarian.png" alt="Vegetarian"/>
      {% endif %}
      {% if dish.price %}
        - {{ dish.price|escape }}
      {% endif %}
    </div>

    {% if dish.description %}
      <div class="post-body">{{ dish.description|escape|linebreaks }}</div>
    {% endif %}

    <div class="post-foot">

      <img class="icon" src="{{ static_ }}/images/like.png" alt="Like"/>
      <b>{{ dish.fans.count }}</b> persons like this
      {% if user_ %}
        {% withfan dish user_ as fan %}
          {{ fan|yesno:"(including you)," }}
          &bull;
          <a href="javascript:void(0);" onclick="changeDishFan_{{ dish.id }}();">
            {{ fan|yesno:"Un-like,Like" }}
          </a>
        {% endwithfan %}
      {% endif %}

      {% if resto_access.can_edit %}
        &bull; <a href="{% url friday.edit_dish resto_id=dish.resto.id dish_id=dish.id %}">Edit</a>
        &bull; <a href="{% url friday.delete_dish resto_id=dish.resto.id dish_id=dish.id %}">Delete</a>
      {% endif %}

    </div>

    <div class="clear"></div>

    {% if user_ %}
      <script type="text/javascript">//<![CDATA[
        function changeDishFan_{{ dish.id }}() {
          $.post(
            "{% url friday.change_dish_fan resto_id=dish.resto.id dish_id=dish.id %}",
            function(data) {
              $("#dish-{{ dish.id }}").after(data).remove();
            }
          );
        }
      //]]></script>
    {% endif %}

  </div>

{% endif %}



